composite data types - a data type constructed using several of the basic data types available in a particular programming language
TYPEStudentRecord DECLARE name : STRING DECLARE age : INTEGEREND TYPE
DECLARE Student : StudentRecordStudent.name <- "Smart Chen"Student.age <- 16a data structure containing several elements of the same data type
DECLARE numList : ARRAY[0:8] OF INTEGERnumList[3] <- 24DECLARE sudoku : ARRAY[0:8,0:8] OF INTEGERsudoku[0,0] <- 3Pseudocode
x
DECLARE numList : ARRAY[1:8] OF INTEGERDECLARE search : INTEGERDECLARE i : INTEGERDECLARE found : BOOLEANfound <- FALSEINPUT searchFOR i <- 1 to length IF numList[i] = search THEN OUTPUT “Found at:”, i found <- TRUE ENDIFNEXT iIF found = FALSE THEN OUTPUT “Not found”ENDIFPython
l = [6, 3, 0, 5, 1, 2, 8, -1, 4]search = int(input())for i in range(len(l)): if l[i] == search: index = i print(f"Found at: {index}") breakelse: index = -1 print("Not found")Pseudocode
x
DECLARE a : ARRAY[1:8] OF INTEGERDECLARE swap : BOOLEANDECLARE i : INTEGERDECLARE j : INTEGERDECLARE temp : INTEGERi <- 1swap <- TRUEWHILE i <= LENGTH(a)-1 AND swap: swap = FALSE FOR j <- 1 to LENGTH(a)-i-1: IF a[j] > a[j+1] THEN temp <- a[j] a[j] <- a[j+1] a[j+1] <- temp swap <- TRUE ENDIFENDWHILEPython
xxxxxxxxxxa = [5, 3, 7, 2, 1, 8, 4, 6]for i in range(len(a)-1): finished = 1 for j in range(len(a)-i-1): if a[j] > a[j+1]: a[j], a[j+1] = a[j+1], a[j] finished = 0 if finished: break3 modes of open files
xxxxxxxxxxDECLARE firstLine : STRING
OPEN file.txt FOR READREADFILE file.txt, firstLineCLOSEFILE file.txt
OPEN file.txt FOR APPENDWRITEFILE file.txt, "this is the second line"CLOSEFILE file.txtADT: a collection of data and a set of operations on that data
a list containing several items operating on the last in, first out (LIFO) principle
a list containing several items operating on the first in, first out (FIFO) principle.
a list containing several items in which each item in the list points to the next item in the list.